package com.gome.ocean.common.enums;

import java.sql.Connection;

/**
 * @author haqiaolong 2016年9月15日 下午6:13:26
 * @since 5.0.0
 */
public enum TransactionIsolation {
    NONE(Connection.TRANSACTION_NONE), READ_COMMITTED(Connection.TRANSACTION_READ_COMMITTED),
    READ_UNCOMMITTED(Connection.TRANSACTION_READ_UNCOMMITTED), REPEATABLE_READ(Connection.TRANSACTION_REPEATABLE_READ),
    SERIALIZABLE(Connection.TRANSACTION_SERIALIZABLE);

    private final int level;

    private TransactionIsolation(int level) {
        this.level = level;
    }
    
    public static String getTransactionIsolation(int level){
        for (TransactionIsolation transactionIsolation : TransactionIsolation.values()) {
            if (transactionIsolation.level == level) {
                return transactionIsolation.name();
            }
        }
        return null;
    }

    public int getLevel() {
        return level;
    }

}
